Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Assembly Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 23rd, 2009, 03:29 PM
Registered User
 
Join Date: Sep 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Display with puthex help

I am trying to write a simple program to manipulate some values and display them at certain "checkpoints." I have the first checkpoint, checkpoint A, at the beginning of the program before anything has been moved, but I still am getting unexpected values in the output. Can someone please tell me where my mistake lies?


;================================================= ==
DOSSEG
.MODEL SMALL,BASIC
;================================================= ========

EXTRN PUTHEX:FAR
EXTRN PUTSTRNG:FAR ;DISPLAY CHARACTER STRING
EXTRN NEWLINE:FAR ;DISPLAY NEWLINE CHARACTER

;
; S T A C K S E G M E N T D E F I N I T I O N
;
.STACK 256
;================================================= ========
;
; D A T A S E G M E N T D E F I N I T I O N
;
.DATA
ALPHA DB 250
BETA DW 01ABH
GAMMA DW 45EFH
LAMDA DB CONSTANT
OMEGA DW 67CDH
CONSTANT EQU 10001001B
;
;================================================= ========
;
; C O D E S E G M E N T D E F I N I T I O N
;
.CODE
ASSUME DS:NOTHING,ES:DGROUP
PR_2_2:
MOV AX,DGROUP ;SET ES-REGISTER TO POINT TO
MOV ES,AX ;CONSTANT DATA SEGMENT
;*** CHECKPOINT A ***
MOV BL,0 ;CODE FOR 8 BIT
XCHG AL,ALPHA ;SWAP WITH AL
CALL PUTHEX ;DISPLAY AL IN HEX
XCHG AL,ALPHA ;RESTORE AL AND ALPHA TO PREVIOUS VALUES
CALL NEWLINE

MOV BL,1
XCHG AX,BETA
CALL PUTHEX
XCHG AX,BETA
CALL NEWLINE

MOV BL,1
XCHG AX,GAMMA
CALL PUTHEX
XCHG AX,GAMMA
CALL NEWLINE

MOV BL,0
XCHG AL,LAMDA
CALL PUTHEX
XCHG AL,LAMDA
CALL NEWLINE

MOV BL,1
XCHG AX,OMEGA
CALL PUTHEX
XCHG AX,OMEGA
CALL NEWLINE

MOV AH,CONSTANT
MOV AL,ALPHA
MOV BX,GAMMA
XCHG AH,BH
XCHG AX,BETA
MOV ALPHA,AH
MOV LAMDA,AL
;*** CHECKPOINT B ***
MOV BL,0 ;CODE FOR 8 BIT
XCHG AL,ALPHA ;SWAP WITH AL
CALL PUTHEX ;DISPLAY AL IN HEX
XCHG AL,ALPHA ;RESTORE AL AND ALPHA TO PREVIOUS VALUES
CALL NEWLINE

MOV BL,1
XCHG AX,BETA
CALL PUTHEX
XCHG AX,BETA
CALL NEWLINE

MOV BL,1
XCHG AX,GAMMA
CALL PUTHEX
XCHG AX,GAMMA
CALL NEWLINE

MOV BL,0
XCHG AL,LAMDA
CALL PUTHEX
XCHG AL,LAMDA
CALL NEWLINE

MOV BL,1
XCHG AX,OMEGA
CALL PUTHEX
XCHG AX,OMEGA
CALL NEWLINE


MOV CX,OMEGA
XCHG BL,CH
MOV GAMMA,BX
MOV OMEGA,CX
;*** CHECKPOINT C ***
MOV BL,0 ;CODE FOR 8 BIT
XCHG AL,ALPHA ;SWAP WITH AL
CALL PUTHEX ;DISPLAY AL IN HEX
XCHG AL,ALPHA ;RESTORE AL AND ALPHA TO PREVIOUS VALUES
CALL NEWLINE

MOV BL,1
XCHG AX,BETA
CALL PUTHEX
XCHG AX,BETA
CALL NEWLINE

MOV BL,1
XCHG AX,GAMMA
CALL PUTHEX
XCHG AX,GAMMA
CALL NEWLINE

MOV BL,0
XCHG AL,LAMDA
CALL PUTHEX
XCHG AL,LAMDA
CALL NEWLINE

MOV BL,1
XCHG AX,OMEGA
CALL PUTHEX
XCHG AX,OMEGA
CALL NEWLINE
.EXIT ;RETURN TO DOS

END PR_2_2

Last edited by humanic; September 24th, 2009 at 01:13 AM..
  #2 (permalink)  
Old January 10th, 2010, 07:14 AM
Authorized User
 
Join Date: Jan 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by humanic View Post
I am trying to write a simple program to manipulate some values and display them at certain "checkpoints." I have the first checkpoint, checkpoint A, at the beginning of the program before anything has been moved, but I still am getting unexpected values in the output. Can someone please tell me where my mistake lies?


;================================================= ==
DOSSEG
.MODEL SMALL,BASIC
;================================================= ========

EXTRN PUTHEX:FAR
EXTRN PUTSTRNG:FAR ;DISPLAY CHARACTER STRING
EXTRN NEWLINE:FAR ;DISPLAY NEWLINE CHARACTER

;
; S T A C K S E G M E N T D E F I N I T I O N
;
.STACK 256
;================================================= ========
;
; D A T A S E G M E N T D E F I N I T I O N
;
.DATA
ALPHA DB 250
BETA DW 01ABH
GAMMA DW 45EFH
LAMDA DB CONSTANT
OMEGA DW 67CDH
CONSTANT EQU 10001001B
;
;================================================= ========
;
; C O D E S E G M E N T D E F I N I T I O N
;
.CODE
ASSUME DS:NOTHING,ES:DGROUP
PR_2_2:
MOV AX,DGROUP ;SET ES-REGISTER TO POINT TO
MOV ES,AX ;CONSTANT DATA SEGMENT
;*** CHECKPOINT A ***
MOV BL,0 ;CODE FOR 8 BIT
XCHG AL,ALPHA ;SWAP WITH AL
CALL PUTHEX ;DISPLAY AL IN HEX
XCHG AL,ALPHA ;RESTORE AL AND ALPHA TO PREVIOUS VALUES
CALL NEWLINE

MOV BL,1
XCHG AX,BETA
CALL PUTHEX
XCHG AX,BETA
CALL NEWLINE

MOV BL,1
XCHG AX,GAMMA
CALL PUTHEX
XCHG AX,GAMMA
CALL NEWLINE

MOV BL,0
XCHG AL,LAMDA
CALL PUTHEX
XCHG AL,LAMDA
CALL NEWLINE

MOV BL,1
XCHG AX,OMEGA
CALL PUTHEX
XCHG AX,OMEGA
CALL NEWLINE

MOV AH,CONSTANT
MOV AL,ALPHA
MOV BX,GAMMA
XCHG AH,BH
XCHG AX,BETA
MOV ALPHA,AH
MOV LAMDA,AL
;*** CHECKPOINT B ***
MOV BL,0 ;CODE FOR 8 BIT
XCHG AL,ALPHA ;SWAP WITH AL
CALL PUTHEX ;DISPLAY AL IN HEX
XCHG AL,ALPHA ;RESTORE AL AND ALPHA TO PREVIOUS VALUES
CALL NEWLINE

MOV BL,1
XCHG AX,BETA
CALL PUTHEX
XCHG AX,BETA
CALL NEWLINE

MOV BL,1
XCHG AX,GAMMA
CALL PUTHEX
XCHG AX,GAMMA
CALL NEWLINE

MOV BL,0
XCHG AL,LAMDA
CALL PUTHEX
XCHG AL,LAMDA
CALL NEWLINE

MOV BL,1
XCHG AX,OMEGA
CALL PUTHEX
XCHG AX,OMEGA
CALL NEWLINE


MOV CX,OMEGA
XCHG BL,CH
MOV GAMMA,BX
MOV OMEGA,CX
;*** CHECKPOINT C ***
MOV BL,0 ;CODE FOR 8 BIT
XCHG AL,ALPHA ;SWAP WITH AL
CALL PUTHEX ;DISPLAY AL IN HEX
XCHG AL,ALPHA ;RESTORE AL AND ALPHA TO PREVIOUS VALUES
CALL NEWLINE

MOV BL,1
XCHG AX,BETA
CALL PUTHEX
XCHG AX,BETA
CALL NEWLINE

MOV BL,1
XCHG AX,GAMMA
CALL PUTHEX
XCHG AX,GAMMA
CALL NEWLINE

MOV BL,0
XCHG AL,LAMDA
CALL PUTHEX
XCHG AL,LAMDA
CALL NEWLINE

MOV BL,1
XCHG AX,OMEGA
CALL PUTHEX
XCHG AX,OMEGA
CALL NEWLINE
.EXIT ;RETURN TO DOS

END PR_2_2
Hi, it's a pretty small and tight program you've written here!

What I cannot see is the NEWLINE source, and the PUTHEX source.

However, from what I can gather you'll require to analyse the xchg commands to get a result. You are swapping out by mistake.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Data Will Not Display When I Click On Display Button sprdave BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 12 February 13th, 2011 12:09 AM
display annumol Hibernate 1 March 21st, 2008 03:43 PM
Datagrid display Lovehead VB.NET 2002/2003 Basics 1 January 20th, 2007 05:12 PM
Display javaLös Java GUI 5 May 12th, 2005 12:29 PM
can't display syounger JSP Basics 3 February 12th, 2004 07:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.