Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Other Programming > Assembly Language
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 23rd, 2009, 04: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 02: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.
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 04: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 01:29 PM
can't display syounger JSP Basics 3 February 12th, 2004 07:46 AM



All times are GMT -4. The time now is 12:59 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.